#include "pch.h"

sf::Music Music;
std::vector<std::pair<sf::SoundBuffer,std::string> > Sounds;
std::vector<sf::Sound> Players;

bool handleMusic()
{	
	Sounds.push_back(std::pair<sf::SoundBuffer,std::string>(sf::SoundBuffer(),"beep"));
	if (!Sounds.back().first.LoadFromFile("data/music/beep.ogg")) return false;
	Sounds.push_back(std::pair<sf::SoundBuffer,std::string>(sf::SoundBuffer(),"heartbeat"));
	if (!Sounds.back().first.LoadFromFile("data/music/heartbeat.ogg")) return false;
	Sounds.push_back(std::pair<sf::SoundBuffer,std::string>(sf::SoundBuffer(),"dead"));
	if (!Sounds.back().first.LoadFromFile("data/music/dead.ogg")) return false;
	Sounds.push_back(std::pair<sf::SoundBuffer,std::string>(sf::SoundBuffer(),"wound_open"));
	if (!Sounds.back().first.LoadFromFile("data/music/wound_open.ogg")) return false;

	Players.resize(Sounds.size());

	return true;
}

void playSound(std::string name)
{
	int i;

	std::vector<std::pair<sf::SoundBuffer,std::string> >::iterator it;
	for (i = 0; i < Sounds.size(); ++i)
		if (Sounds[i].second == name)
			break;

	Players[i].SetBuffer(Sounds[i].first);
	Players[i].Play();
}